package com.cy.stone.system.domain.clientobject.dict;

import com.cy.stone.common.base.AddGroup;
import com.cy.stone.common.base.EditGroup;
import com.cy.stone.system.infrastructure.database.entity.DictTypeEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

/**
 * 字典类型入参
 * @author Wings
 * @since 2023-12-18
 */
@Data
@Schema(name = "字典类型入参")
public class DictTypeCO {

    @Schema(name = "ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "ID不能为空", groups = EditGroup.class)
    private String id;

    @Schema(name = "字典类型代码", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "字典类型代码不能为空", groups = {AddGroup.class, EditGroup.class})
    private String dictType;

    @Schema(name = "字典类型名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "字典类型名称不能为空", groups = {AddGroup.class, EditGroup.class})
    private String dictName;

    public static DictTypeEntity toAddEntity(DictTypeCO dictTypeCO) {
        DictTypeEntity dictTypeEntity = new DictTypeEntity();
        dictTypeEntity.setDictType(dictTypeCO.getDictType());
        dictTypeEntity.setDictName(dictTypeCO.getDictName());
        return dictTypeEntity;
    }
}
